home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 1999 #1 / Amiga Plus 1999 #1.iso / System-Boost / Workbench / LFSystemBinder / compagnons / Registry / Examples / TestClass.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-06-21  |  1.5 KB  |  62 lines

  1. /*
  2.  *      TestClass.c
  3.  *          © LFSoft 1995
  4.  *
  5.  *      Test Classes registering.
  6.  *
  7.  *      19/07/1995  First version
  8.  *
  9.  *      This code is fully a dommain public: Use it as you want...
  10.  *
  11.  *      Testing:
  12.  *      ~~~~~~~~
  13.  *      + First: Register your class
  14.  *          Shell #7 STAT-RAM: > TestClass MyClass
  15.  *              -> 3
  16.  *          3 is uniq id for (MyClass).
  17.  *
  18.  *      + Second: Free your class
  19.  *          Shell #7 STAT-RAM: >TestClass -u 3
  20.  *
  21.  *      Run ListRegistry to see classes' list...
  22.  *
  23.  *   Note:
  24.  *       * All libraries (but registery.library) are openned and closed
  25.  *   automaticaly by DICE's autoinit feature. You must add some code for
  26.  *   others compilers.
  27.  */
  28.  
  29. #include <proto/exec.h>
  30. #include <proto/registry.h>
  31. #include <stdio.h>
  32. #include <string.h>
  33. #include <stdlib.h>
  34.  
  35. struct Library *RegistryBase=NULL;
  36.  
  37. void cleanup( void ){   // We must close the library
  38.     if(RegistryBase)
  39.         CloseLibrary(RegistryBase);
  40. }
  41.  
  42. void main(int ac, char **av){
  43.     if(ac < 2){ // Help ???
  44.         puts("Usage :\n\tTestClass Nom\n\tTestClass -u ClassID\n");
  45.         exit(10);
  46.     }
  47.  
  48.     if(!(RegistryBase = OpenLibrary("registry.library",0))){
  49.                             //AutoOpen can't be used 'cause no glue code
  50.         puts("Can't open registry.library");
  51.         exit(20);
  52.     }
  53.     atexit(cleanup);
  54.  
  55.     if(!strcmp(av[1],"-u"))
  56.         RL_UnRegisterClass(atol(av[2]));
  57.     else
  58.         printf("-> %d\n",RL_RegisterClass(av[1]));
  59.  
  60.     exit(0);    // That's all folks
  61. }
  62.